package com.ist.viewpagerhelper.activity.loop;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.ist.viewpagerhelper.ContractUtils;
import com.ist.viewpagerhelper.R;
import com.ist.viewpagerhelper.bean.ViewPagerBean;
import com.ist.viewpagerhelper.view.BannerViewPagerTail;
import com.ist.viewpagerhelper.indicator.ZoomIndicator;

public class AutoActivity extends AppCompatActivity {

    private static final String TAG = "zsr";
    //展示三张，其实是有五张
    private static final String[] RESURL = {
            "http://img.mukewang.com/54bf7e1f000109c506000338-590-330.jpg",
            "http://upload.techweb.com.cn/2015/0114/1421211858103.jpg",
            "http://img1.cache.netease.com/catchpic/A/A0/A0153E1AEDA115EAE7061A0C7EBB69D2.jpg",
            "http://image.tianjimedia.com/uploadImages/2015/202/27/57RF8ZHG8A4T_" +
                    "5020a2a4697650b89c394237ba9ffbb45fe8555a2cbec-6O6nmI_fw658.jpg"};
    private static final Integer[] RES = {R.mipmap.guide1,R.mipmap.guide2,R.mipmap.guide3,
            R.mipmap.guide4 };
    private BannerViewPagerTail mBannerViewPager;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_auto);
        mBannerViewPager = (BannerViewPagerTail) findViewById(R.id.viewpager);
        ZoomIndicator scaleIndicator = (ZoomIndicator) findViewById(R.id.bottom_scale_layout);

        //这里不适用 list<view> 直接加载view的方式，因为是动态添加，这个view 有多个 parent，报错
        // 所以，这里我们传递个图片的练级或者 id过去即可

        ViewPagerBean bean =  new ViewPagerBean.Builder()
                .setViewPager(mBannerViewPager)
                .setIndicator(scaleIndicator)
                .setDataObjects(RESURL)
                .setDataCount(RESURL.length)
                .setMode(ContractUtils.LOOP_TAIL_MODE)
                .builder();

        mBannerViewPager.setViewPagerBean(bean);

        // 用本地数据
        BannerViewPagerTail bannerViewPager2 = (BannerViewPagerTail) findViewById(R.id.viewpager2);
        ViewPagerBean bean2 =  new ViewPagerBean.Builder()
                .setViewPager(bannerViewPager2)
                .setDataObjects(RES)
                .setDataCount(RES.length)
                .setMode(ContractUtils.LOOP_TAIL_MODE)
                .builder();

        bannerViewPager2.setViewPagerBean(bean2);



    }

    @Override
    protected void onPause() {
        super.onPause();
        mBannerViewPager.onPause();
    }

    @Override
    protected void onResume() {
        super.onResume();
        mBannerViewPager.onResume();
    }
}
